home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-04-28 | 37.1 KB | 1,245 lines |
- \ JFVGFP.DIEEE Revised: 1/29/89 Length 15,580 bytes with max-inline=16
- \
- \ A double precision IEEE floating point JForth implementation
- \ of the Forth Vendors Group Floating Point Extension
- \ Dr. Dobb's Journal September 1984.
- \
- \ Copyright 1987 by
- \ David J. Sirag,
- \ 17215 S. Harvest Ave.,
- \ Cerritos, CA 90701.
- \ Permission is hereby granted to distribute this code with JFORTH
- \ with the provision that this copyright notice and permission
- \ statement are included with the code. It may be used by licensed
- \ users of JFORTH with the same restrictions as if it were part of
- \ JFORTH.
- \
- \ >>>>>>>>>>>>>>>
- \ Modifications by Phil Burk & Mike Haas, Delta Research, 8/15/88
- \ Some modifications were needed to take advantage
- \ of some of JForth 2.0's new features, ie. Clone,
- \ Precompiled Assembler Module and Hashing.
- \ References to Status Register changed to use GetCC exec call.
- \
- \ MOD: PLB 7/10/89 Changed SWIVEL2 to SWAP in INT.
- \ Set FPWARN to TRUE instead of 1 for AND
- \ MOD: PLB 9/19/89 Fixed F#BYTES, Fixed NEG check in F**.
- \ MOD: PLB 4/24/90 Don't call SMUDGE0123
- \ MOD: PLB 6/5/90 Removed CRs from FLN and FLOG
- \ MOD: PLB 7/31/90 FIX converted to high level to eliminate bug
- \ MOD: PLB 8/31/90 Added check to FLOAT for very large neg numbers.
- \ 00001 PLB 9/21/91 Put ABORTs after FP INFINITY warnings, cleanup
- \ 00002 PLB 9/23/91 Trap FPEXP>1023 in F>TEXTs, return "Infinity"s
- \ 00003 PLB 1/4/92 Added FLOAT.NUMBER? FASTFP.NUMBER? FNUMBER?
- \ 00004 PLB 2/25/92 Fixed AUTO.TERM which used to call AUTO.INIT
- \ 00005 PLB 4/28/92 Fixed large negative numbers >F and UNPACK
-
- \ <<<<<<<<<<<<<<<
- \
- \ Arithmetic operators:
- \ F+ F- F* F/ FABS FNEGATE FMAX FMIN F2* F2/
- \
- \ Transcendental functions:
- \ FLOG FLN FSIN FCOS FTAN FSINH FCOSH FTANH
- \ FALOG FALN FASIN FACOS FATAN FSQRT F**
- \ FCS FATCS DEG>RAD RAD>DEG DEG/RAD PI PI/2 2PI
- \
- \ Logical operators:
- \ F0= F0< F0> F= F< F>
- \ F0<> F0<= F0>= F<= F>= F<>
- \ FEQ FLT FGT FNE FLE FGE FVS FVC
- \
- \ Stack operators:
- \ FDROP FDUP FOVER FSWAP FROT
- \ F>R FR> FR@ FRDROP
- \ FNOVER NFOVER FNSWAP NFSWAP
- \ FFNROT FNFROT NFFROT FNNROT NFNROT NNFROT
- \ FCELL FCELL+ FCELL- FCELLS FCELL/ FCELLU/
- \
- \ Number handling operators:
- \ FLOAT FIX (rounded) INT (truncated)
- \ F! F@ FCONSTANT FVARIABLE FARRAY
- \ FNUMBER PACK UNPACK F#BYTES F#PLACES
- \
- \ Display operators:
- \ F. E. ENG. PLACES (sets FFLD described below)
- \ F.R E.R ENG.R (display rounded and right justified in field)
- \ F>TEXT F>ETEXT F>ENGTEXT ( create f., e., and eng. strings )
- \
- \ Display operators & variables - not in FVG84:
- \ FLD - total width of field for number displays
- \ FFLD - width of fractional field for F. - places after decimal
- \ EFFLD - width of fractional field for E. and ENG.
- \ F.EXMAX - maximum exponent for decimal form display for F.
- \ F.ENDPOINT - flag indicating whether to use a point at end of F. display
- \ DP-CHARS - symbols for decimal point and comma - allows Euro style
- \ E.PLUS - flag for "E+01" rather than "E01" - aligns with "E-01"
- \ EXPSYMBOL - symbol for "E" for E. and ENG. - allows upper or lower "E"
- \ COMMAS - use commas (from Jforth) in F. and integer displays
- \ NO-COMMAS - don't use commas in F. and integer displays
- \ FPWARN - flag to display floating point warning messages
- \
- \ Number interpreters - fp only interpreted if base is 10 - not in FVG84:
- \ FLOAT.INTERPRET - integers, decimal form and "E" form real numbers
- \ FASTFP.INTERPRET - integers and decimal form real numbers
- \ FIX.INTERPRET - integers
- \ NTYPE - number type variable 1 = int, 2 = fp, 0 = not number
- \
- \ Significant digits:
- \ The fp number interpreters and fp diplay routines provide
- \ 15 significant digit conversions to and from floating point.
- \ For example, 1.234567890123456 F. will display 1.23456789012346.
- \ The transendental functions use the ffp library; thus, they are
- \ accurate to about 7 significant digits.
-
- only forth definitions
-
- ANEW FP-DEFINITIONS
-
- : DIEEE ;
-
- : OPEN-MATHLIBS ( --- )
- mathieeedoubbas? mathieeedoubtrans? mathtrans? ;
- : CLOSE-MATHLIBS ( --- )
- -mathieeedoubbas -mathieeedoubtrans -mathtrans ;
- ." Opening Math Libraries" cr
- open-mathlibs decimal
-
- \ Stack and memory operators ==FVG84 required (except as noted)
- \ Even when these operators are identical to an integer equivalent,
- \ the fp form of the operator should be used in application code so
- \ that the application will function properly when a floating point
- \ inplementation with a different number of bytes is substituted.
-
- : F! 2! both ;
- : F@ 2@ both ;
- : FDROP 2drop both ;
- : FDUP 2dup both ;
- : FOVER 2over both ;
- : FSWAP 2swap both ;
-
- code FROT dsp a@+ 0dr dn move dsp a@+ 1dr dn move
- dsp a@+ 2dr dn move dsp a@+ 3dr dn move
- dsp a@ 4dr dn move 2dr dn dsp a@ move
- 1dr dn dsp -a@ move 0dr dn dsp -a@ move
- tos dn dsp -a@ move 4dr dn dsp -a@ move
- 3dr dn tos dn move
- rts end-code
-
- \ return stack operators ==extensions to FVG84
-
- code F>R dsp a@+ rp -a@ move tos dn rp -a@ move
- dsp a@+ tos dn move both rts end-code
-
- code FR> tos dn dsp -a@ move rp a@+ tos dn move
- rp a@+ dsp -a@ move both rts end-code
-
- code FR@ tos dn dsp -a@ move rp a@ tos dn move
- rp 4 an+w dsp -a@ move both rts end-code
-
- code FRDROP 8 # rp an addq both rts end-code
-
-
- \ fixed number type stack operators ==extensions to FVG84
-
- code FNOVER ( r n --- r n r )
- tos dn dsp -a@ move dsp 4 an+w tos dn move
- dsp 8 an+w dsp -a@ move
- both rts end-code
-
- code NFOVER ( n r --- n r n )
- tos dn dsp -a@ move dsp 8 an+w tos dn move
- both rts end-code
-
- : FNSWAP ( r n --- n r ) -rot both ;
-
- : NFSWAP ( n r --- r n ) rot both ;
-
- code FFNROT ( r1 r2 n --- r2 n r1 )
- tos dn 1dr dn move
- dsp a@+ 2dr 3dr 4dr tos movem
- tos dn 0dr dn move
- 4dr dn tos dn move
- 0dr 1dr 2dr 3dr dsp -a@ movem
- both rts end-code
-
- : FNFROT ( r1 n r2 --- n r2 r1 ) ffnrot ;
-
- code NFFROT ( n r1 r2 --- r1 r2 n )
- tos dn 0dr dn move
- dsp a@+ 1dr 2dr 3dr tos movem
- 0dr 1dr 2dr 3dr dsp -a@ movem
- both rts end-code
-
- : FNNROT ( r n1 n2 --- n1 n2 r ) 2swap both ;
-
- code NFNROT ( n1 r n2 --- r n2 n1 )
- tos dn 0dr dn move
- dsp a@+ 1dr 2dr tos movem
- 0dr 1dr 2dr dsp -a@ movem
- both rts end-code
-
- : NNFROT ( n1 n2 r --- n2 r n1 ) nfnrot both ;
-
-
- \ Fp cell operators ==extensions to FVG84
-
- code FCELL+ ( n --- n ) 8 # tos dn addq both rts end-code
- code FCELL- ( n --- n ) 8 # tos dn subq both rts end-code
- code FCELLS ( n --- n ) 3 # tos dn lsl both rts end-code
- code FCELL/ ( n --- n ) 3 # tos dn lsr both rts end-code
- code FCELLU/ ( n --- n ) 3 # tos dn lsr both rts end-code
-
- : FVARIABLE create 0 , 0 , does> ;
-
- : FCONSTANT create , , does> f@ ;
-
- : FARRAY \ fp array with size error checking == extension to FVG84
- create dup , 0 do -1 , -1 , loop
- does> [ also assembler
- dsp a@ 0dr dn move
- 1dr dn clr
- org tos 0 an+r+b 0dr dn cmp
- 1dr dn byte scc
- 3 # 0dr dn asl
- 0dr dn tos dn add
- 4 # tos dn addq
- tos dn dsp a@ move
- 1dr dn tos dn move
- previous ] if ." farray size" 0 error then ;
-
- 8 constant FCELL \ number of bytes required for fp
- -1 -1 fconstant F-INFINITY \ internal use
- -1 $ 7fffffff fconstant FINFINITY \ internal use
- $ 20000 constant FPOV \ internal use
- variable FPWARN \ if true, fp warning messages will display
- \ 1 fpwarn ! \ ==extension to FVG84
- TRUE fpwarn ! \ ==extension to FVG84 ( use TRUE for AND )
- variable FPSTAT \ status of last fp operation
- \ bit flags (hex) 20000 = overflow
- \ 40000 = zero 80000 = negative
- \ other bits are undefined ==FVG84 optional
-
-
- : FPCEND ( -- , compile extend )
- compile b->s
- ;
- code (@>CCR) ( cc -- cc , copy codes to ccr )
- org 7dr 0 an+r+b move-to-ccr
- inline rts
- end-code
-
- \ These macros must compile BSR references to FPSTAT
- \ for proper cloning.
- : FPSTAT->CCR \ macro: move fp status to cond code reg
- compile fpstat
- compile (@>ccr)
- ;
-
-
- \ Fp logical operators that test the fpstat condition code of the last
- \ fp operation. This allows very fast tests. The resulting test flag
- \ is placed on the stack. They do not set the condition codes in fpstat.
- \ Fvs and fvc test the overflow bit for being set or clear.
- \ ==extensions to FVG84
-
- code FEQ ( --- f ) fpstat->ccr tos dn byte seq fpcend both rts end-code
- code FLT ( --- f ) fpstat->ccr tos dn byte slt fpcend both rts end-code
- code FGT ( --- f ) fpstat->ccr tos dn byte sgt fpcend both rts end-code
- code FNE ( --- f ) fpstat->ccr tos dn byte sne fpcend both rts end-code
- code FLE ( --- f ) fpstat->ccr tos dn byte sle fpcend both rts end-code
- code FGE ( --- f ) fpstat->ccr tos dn byte sge fpcend both rts end-code
- code FVS ( --- f ) fpstat->ccr tos dn byte svs fpcend both rts end-code
- code FVC ( --- f ) fpstat->ccr tos dn byte svc fpcend both rts end-code
-
- ASM SWIVEL2 ( a b c d -- b a d c )
- move.l (dsp),D0
- move.l tos,(dsp)
- move.l d0,tos
- move.l $8(dsp),D0
- move.l $4(dsp),$8(dsp)
- move.l d0,$4(dsp)
- rts
- end-code
-
-
- \ Fp logical operators that compare two fp numbers on the stack.
- \ The two numbers are removed from the stack and replaced with
- \ the resulting test flag. They do not set the condition codes
- \ in fpstat. ==FVG84 required (except as noted)
-
- \ Make macro using both
- code (FPC)
- ] swivel2 ret:sr callvoid mathieeedoubbas_lib IEEEDPCmp [
- tos dn move-to-ccr
- end-code
-
- : FPC compile (FPC) ;
-
- code F= ( r1 r2 --- f ) fpc tos dn byte seq fpcend both rts end-code
- code F< ( r1 r2 --- f ) fpc tos dn byte slt fpcend both rts end-code
- code F> ( r1 r2 --- f ) fpc tos dn byte sgt fpcend both rts end-code
- \ following are ==FVG84 extensions
- code F<> ( r1 r2 --- f ) fpc tos dn byte sne fpcend both rts end-code
- code F<= ( r1 r2 --- f ) fpc tos dn byte sle fpcend both rts end-code
- code F>= ( r1 r2 --- f ) fpc tos dn byte sge fpcend both rts end-code
-
- \ Fp logical operators that test the number on the top of the stack.
- \ The number is replaced on the stack with the test result flag.
- \ They do not set the condition codes in fpstat.
- \ ==FVG84 required (except as noted)
-
- code F0= ( r --- f )
- dsp a@+ tst
- 1 # tos dn lsl
- tos dn byte seq fpcend
- both rts end-code
-
- code F0< ( r --- f )
- dsp a@+ tst
- 31 # tos dn bclr 1 beq
- tos dn tst
- 1 br: tos dn byte sne fpcend
- both rts end-code
-
- code F0> ( r --- f )
- dsp a@+ tst
- 1 # tos dn lsl
- tos dn byte shi fpcend
- both rts end-code
-
- code F0<> ( r --- f )
- dsp a@+ tst \ ==extension to FVG84
- 1 # tos dn lsl
- tos dn byte sne fpcend
- both rts end-code
-
- code F0<= ( r --- f )
- dsp a@+ tst \ ==extension to FVG84
- 1 # tos dn lsl
- tos dn byte sls fpcend
- both rts end-code
-
- code F0>= ( r --- f )
- dsp a@+ tst \ ==extension to FVG84
- 31 # tos dn bclr 1 beq
- tos dn tst
- 1 br: tos dn byte seq fpcend
- both rts end-code
-
- \ Fp arithmetic operators ==FVG84 required (except as noted)
- \ Fpstat condition codes are set by arithmetic operators
-
- : F+ ( r1 r2 --- r )
- swivel2 ret:sr dcall mathieeedoubbas_lib IEEEDPAdd fpstat w! swap
- ;
-
- : F- ( r1 r2 --- r )
- swivel2 ret:sr dcall mathieeedoubbas_lib IEEEDPSub fpstat w! swap
- ;
-
- : F* ( r1 r2 --- r )
- swivel2 ret:sr dcall mathieeedoubbas_lib IEEEDPMul fpstat w! swap
- ;
-
- : F/ ( r1 r2 --- r )
- 2dup f0= abort" F/ - Divide by zero!"
- swivel2 ret:sr dcall mathieeedoubbas_lib IEEEDPDiv fpstat w! swap
- ;
-
- code TEST.NZ ( N -- N ccr )
- tos dn dsp -a@ move
- tos dn tst 9 beq
- tos dn byte tst
- 9 br: \ 7dr dn move-from-sr
- 4 abs.l 0ar an move
- 0ar $ -210 an+w jsr
- 0 # tos dn moveq
- 0dr dn tos dn word move
- both
- rts
- end-code
-
- : SET-FPSTAT \ macro: test tos, set n & z in fpstat
- compile test.nz
- compile fpstat
- compile w!
- ;
-
- code CC2D0 ( get the cc, put in d0, wrecks a0 also )
- 4 abs.w 0ar an move
- 0ar $ -210 an+w jsr
- both end-code
-
- code F2* ( r --- r )
- tos dn 1dr dn move
- $ 100000 # tos dn add
- set-fpstat
- tos dn 1dr dn eor 1dr dn tst 1 bge
- $ 100000 # tos dn sub -1 # dsp a@ move
- $ 7fffffff # tos dn or
- \ 2 # byte ori-ccr
- \ org 4dr 0 an+r+b move-from-sr
- ] cc2d0 [
- 2 # 0dr dn word or
- ] fpstat [
- 0dr dn org tos 0 an+r+b word move
- dsp a@+ tos dn move
- 1 br: rts end-code
-
- code F2/ ( r --- r )
- tos dn 1dr dn move
- $ 100000 # tos dn sub
- set-fpstat
- tos dn 1dr dn eor 1dr dn tst 1 bge
- tos dn clr dsp a@ clr
- ] cc2d0 fpstat [
- 0dr dn org tos 0 an+r+b word move
- 4 # dsp an addq
- tos dn clr
- 1 br: rts end-code
-
- code FABS ( r --- r )
- $ 7fffffff # tos dn and
- set-fpstat
- both rts end-code
-
- code FNEGATE ( r --- r )
- fpstat # 4dr dn move \ change sign
- tos dn tst 1 beq
- $ 80000000 # tos dn eor
- 1 br: set-fpstat
- both rts end-code
-
- code FMAX ( r1 r2 --- r )
- dsp a@+ 0dr 1dr 2dr movem
- 1dr dn 3dr dn move 2dr dn 4dr dn move
- tos dn 0ar an move 0dr dn 1ar an move
- 31 # 1dr dn bclr 1 beq
- 2dr dn neg 1dr dn negx
- 1 br: 31 # tos dn bclr 2 beq
- 0dr dn neg tos dn negx
- 2 br: 0dr dn 2dr dn sub \ fpstat # 0dr dn move
- tos dn 1dr dn subx 3 blt
- 4dr dn dsp -a@ move 3dr dn tos dn move 4 bra
- 3 br: 1ar an dsp -a@ move 0ar an tos dn move
- 4 br: set-fpstat
- both rts end-code
-
- code FMIN ( r1 r2 --- r )
- dsp a@+ 0dr 1dr 2dr movem
- 1dr dn 3dr dn move 2dr dn 4dr dn move
- tos dn 0ar an move 0dr dn 1ar an move
- 31 # 1dr dn bclr 1 beq
- 2dr dn neg 1dr dn negx
- 1 br: 31 # tos dn bclr 2 beq
- 0dr dn neg tos dn negx
- 2 br: 0dr dn 2dr dn sub \ fpstat # 0dr dn move
- tos dn 1dr dn subx 3 bgt
- 4dr dn dsp -a@ move 3dr dn tos dn move 4 bra
- 3 br: 1ar an dsp -a@ move 0ar an tos dn move
- 4 br: set-fpstat
- both rts end-code
-
-
- \ Fp conversion routines ==FVG84 required (except as noted)
- \ Fpstat condition codes are set by conversion routines
-
- : (FLOAT) ( n --- r ) \ for internal use
- ret:sr dcall mathieeedoubbas_lib IEEEDPFlt fpstat w! swap
- ;
-
- code $200000/mod \ for internal use
- tos dn 0dr dn move 3dr dn byte slt
- 3dr dn word ext 3dr dn ext
- dsp a@ 1dr dn move 1dr dn 2dr dn move
- $ ffe00000 # 3dr dn and $ 1fffff # 2dr dn and
- 3dr dn 2dr dn or 2dr dn dsp a@ move
- 21 # 4dr dn move 4dr dn tos dn asr
- 4dr dn 1dr dn lsr 11 # 4dr dn move
- 4dr dn 0dr dn lsl 1dr dn 0dr dn or
- 0dr dn dsp -a@ move rts end-code
-
- : FLOAT ( n --- r ) \ Convert integer to fp
- dup abs $ 200000 >
- IF dup 0< \ This doesn't seem to handle negative
- IF negate true \ so convert it to positive first.
- ELSE false
- THEN swap
- s->d \ assumes that (float) can handle
- $200000/mod drop (float) \ 21 bits accurately
- $ 1500000 + nfswap (float) f+
- nfswap
- IF fnegate
- THEN
- ELSE (float)
- THEN ;
-
- : INT ( r --- n ) \ truncate and convert to integer
- \ swivel2 ret:sr call mathieeedoubbas_lib IEEEDPFix dup fpstat w!
- \ fpov and
- \ fpwarn @ AND
- \ IF ." ...warning fp too large for int" cr
- \ THEN
- \ Use SWAP instead of SWIVEL2 because only one argument.
- \ Don't check for overflow because of false alarms for negative numbers.
- SWAP call mathieeedoubbas_lib IEEEDPFix
- ;
-
- 1 float fconstant F1
- 100000000 float fconstant F100000000
- f1 f100000000 f/ fconstant F.00000001
-
- : FIX ( r -- i , round then integerize )
- fdup f0>
- IF [ f1 f2/ ] dliteral
- ELSE [ f1 f2/ fnegate ] dliteral
- THEN
- f+ INT
- ;
-
- \ Fp transendental functions. Fpstat condition codes are set by these
- \ functions. ==FVG84 required or optional (except as noted).
- \ They are based on the ffp library; thus, they are accurate to about
- \ 7 significant digits.
- \ If transcendental functions are wanted (or not wanted)
- \ place true (or false) prior to the .if on the next line
- \ The transendental functions use about 2000 bytes.
-
- true .if
-
- 4614256656552045848. fconstant PI
- pi $ 100000 - fconstant PI/2 \ ==extension to FVG84
- pi $ 100000 + fconstant 2PI \ ==extension to FVG84
- 4633260481411531256. fconstant DEG/RAD \ ==extension to FVG84
-
- code DIEEE->FFP ( r.dieee --- r.ffp ) \ convert double ieee fp to ffp fp
- tos dn 0dr dn move dsp a@+ 1dr dn move \ internal use
- 8 # tos dn rol 4 # tos dn rol
- tos dn 2dr dn move $ 7ff # tos dn and
- $ -1000 # 2dr dn and 1 # 2dr dn lsr
- 31 # 2dr dn bset 1dr dn swap
- 5 # 1dr dn word lsr 1dr dn ext
- 1dr dn 2dr dn or
- $ 80 # 2dr dn add 1 bcc
- 1 # 2dr dn roxr 1 # tos dn addq
- 1 br: $ -100 # 2dr dn and
- 958 # tos dn sub 2 bgt
- tos dn clr 2dr dn clr 0dr dn clr
- 2 br: $ 7f # tos dn cmp 3 ble
- $ 7f # tos dn move $ ffffff00 # 2dr dn move
- 3 br: 0dr dn tst 4 bpl 7 # tos dn bset
- 4 br: 2dr dn tos dn or rts end-code
-
- code FFP->DIEEE ( r.ffp --- r.dieee ) \ convert ffp fp to double ieee
- tos dn 0dr dn move 3 beq \ for internal use
- 7 # tos dn bclr
- $ ffffff7f # tos dn cmp 1 bne
- 0dr dn tos dn move 8 # tos dn ror
- 7 # 0dr dn bset 3 bra
- 1 br: $ 7f # tos dn and 958 # tos dn add
- 0dr dn byte tst 2 bpl
- 11 # tos dn bset
- 2 br: tos dn swap 4 # tos dn lsl
- 0dr dn swap 5 # 0dr dn rol
- 0dr dn 1dr dn move $ fffff # 1dr dn and
- 1dr dn tos dn or $ e0000000 # 0dr dn and
- 3 br: 0dr dn dsp -a@ move rts end-code
-
-
- : F** ( r1 r2 --- r )
- fover f0<
- IF fdrop fdrop 0 0
- ." ...warning - power of negative number" cr
- ELSE swivel2 2swap
- ret:sr dcall mathieeedoubtrans_lib IEEEDPPow fpstat w! swap
- THEN
- ;
-
- : FSQRT ( r --- r )
- 2dup f0< abort" Error - square root of negative number!"
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPSqrt fpstat w! swap
- ;
-
- : FLN ( r --- r )
- 2dup f0<= abort" Error - ln of 0 or negative number "
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPLog fpstat w! swap
- ;
- : FLOG ( r --- r )
- 2dup f0<= abort" Error - log of 0 or negative number "
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPLog10 fpstat w! swap
- ;
-
- : FALOG ( r --- r )
- 0 $ 40240000 ( 10.0 ) 2swap f**
- ;
-
- : FALN ( r --- r )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPExp fpstat w! swap
- ;
-
-
- : FSIN ( r.rad --- r )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPSin fpstat w! swap
- ;
-
- : FCOS ( r.rad --- r )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPCos fpstat w! swap
- ;
-
- : FTAN ( r.rad --- r )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPTan fpstat w! swap
- ;
-
- : FASIN ( r --- r.rad )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPASin fpstat w! swap
- ;
-
- : FACOS ( r --- r.rad )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPACos fpstat w! swap
- ;
-
- : FATAN ( r --- r.rad )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPAtan fpstat w! swap
- ;
-
- : FSINH ( r.rad --- r )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPSinh fpstat w! swap
- ;
-
- : FCOSH ( r.rad --- r )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPCosh fpstat w! swap
- ;
-
- : FTANH ( r.rad --- r )
- swap ret:sr dcall mathieeedoubtrans_lib IEEEDPTanh fpstat w! swap
- ;
-
- FVARIABLE FCS-PAD ( holds result from sincos )
- : FCS ( r.rad --- r.sin r.cos ) \ cosine & sine - spsincos
- swap fcs-pad >abs -rot
- ret:sr dcall mathieeedoubtrans_lib IEEEDPSinCos fpstat w!
- swap fcs-pad F@
- ;
-
- : FATCS ( r.sin r.cos --- r.rad ) \ four quadrant atan - fortran's atan2
- fdup f0< if -1 else 0 then >r \ ==extension to FVG84
- fdup f0=
- IF fdrop
- f0>
- IF pi/2
- ELSE pi/2 fnegate
- THEN
- ELSE f/ fatan
- THEN
- r> if pi fover f0> if f- else f+ then then ;
-
- : DEG>RAD deg/rad f/ ; \ convert degrees to radians ==extension to FVG84
- : RAD>DEG deg/rad f* ; \ convert radians to degrees ==extension to FVG84
-
- \ end of transendental functions
- .then
-
-
- \ Fp ascii conversion and display routines. Fpstat is not set by the ascii
- \ conversion and display routines. Fpstat from a prior fp operation is not
- \ preserved through these routines.
- \ ==FVG84 required, optional, or extension is indicated with each routine.
-
- variable FFLD \ Fractional field - digits to display after decimal
- -1 ffld ! \ when displayed with f. min=0 max=15 (-1=variable width)
- \ ==extension to FVG84
-
- variable F.EXMAX \ Maximum exponent for which to use for decimal form
- 12 f.exmax ! \ when displayed with f. (larger exponents use e-form)
- \ ==extension to FVG84
-
- variable F.ENDPOINT \ Flag indicating to put a point at the end
- -1 f.endpoint ! \ of a f. display when appropriate.
- \ 1 = point 0 = no point ==extension to FVG84
-
- variable EFFLD \ fractional field in mantissa when displayed with e.
- 6 effld ! \ min = 0 max = 14 (no variable width feature)
- \ ==extenstion to FVG84
-
- variable E.PLUS \ true indicates to place "+" after "e" (e.g. "e+06")
- 1 e.plus ! \ ==extension to FVG84
-
- variable EXPSYMBOL \ contains ascii symbol for exponent in e form
- ascii e expsymbol ! \ ==extension to FVG84
-
- \ 4 constant F#BYTES \ number of bytes in a floating point number
- 8 constant F#BYTES \ number of bytes in a floating point number
- \ ==FVG84 optional
-
- 15 constant F#PLACES \ maximum number of significant digits in fp number
- \ ==FVG84 optional
-
- variable DP-CHARS \ double precision characters ==FVG84 extension
- ascii . dp-chars w! \ . is normal decimal point
- ascii , dp-chars 2+ w! \ , is normal digits separator
-
- variable SIGDIG variable UNPP2 \ for internal use
- fvariable UNPREAL fvariable UNPMULT variable UNPEX
- 40 farray FPEXP.ARY 40 farray -FPEXP.ARY
-
-
- redef? @ redef? off
- : xx f1 40 0 do fdup i fpexp.ary f! f100000000 f* loop fdrop ;
- xx
-
- : yy f1 40 0 do fdup i -fpexp.ary f! f.00000001 f* loop fdrop ;
- yy
- forget xx
- redef? !
-
- : DVARIABLE fvariable ; \ dvariables are necessary in conversion routines
-
- code D0= dsp a@+ tos dn or tos dn byte seq
- tos dn word ext tos dn ext
- rts end-code
-
- : FLOATEXP ( n --- n r ) \ convert int exp to fp power of 10
- dup 0> if \ factored to real and int power of 2
- dup 309 < if \ for internal use
- 8 /mod swap
- 0 1 rot ?dup if 0 do 5 * swap 1+ swap loop then
- float nnfrot fpexp.ary f@ f*
- else drop 0 finfinity
- fpwarn @ if ." FLOATEXP ... warning fp infinity " abort then
- then
- else
- dup -309 > if
- abs 8 /mod swap
- 0 1 rot ?dup if abs 0 do 5 * swap 1- swap loop then
- rot -fpexp.ary f@ nfswap float f/
- else drop 0 0. then
- then
- ;
-
- : FPEXP ( r -- iexponent-binary )
- swap drop $ 100000 / $ 7ff and $ 3fe -
- ; \ for internal use
- \ 1.23 fpexp = 1
-
- code R*E16->D ( r --- d ) \ convert fp * E16 to double int - internal use
- tos dn 1dr dn move dsp a@ 0dr dn move
- $ fffff # tos dn and 20 # tos dn bset
- 31 # 1dr dn btst 1 beq
- 0dr dn neg tos dn negx
- 1 br: $ 7ff00000 # 1dr dn and 1dr dn swap
- 4 # 1dr dn lsr 1076 # 1dr dn sub 3 blt
- 2 br: 1 # 0dr dn lsl 1 # tos dn roxl
- 1dr dn 2 word dbra
- 3 br: 0dr dn dsp a@ move
- rts end-code
-
- : >F ( d --- r ) \ converts a double integer with decimal to float
- \ uses position of decimal point indicated by dpl
- \ to position decimal point in floating point number
- \ modified by Rob Andre to fix large negative number problem 00005
- ddup or
- IF \ max = 18 digits ==extension to FVG84
- dup 0<
- >r
- dabs
- $200000/mod $200000/mod drop (float) $ 2a00000 +
- nfswap (float) $ 1500000 + f+ nfswap (float) f+
- dpl @ dup 0>
- IF floatexp nfswap $ 100000 * + f/
- ELSE drop
- THEN
- r>
- IF fnegate
- THEN
- THEN
- 0 dpl !
- ;
-
-
- : UNPACK ( r --- d n ) \ float to d: mantissa 12345678901234567
- \ 16 implied decimal places n: exponent
- \ ==FVG84 optional
- unpreal f! f1 unpmult f! 0 unpex ! 0 unpp2 !
- unpreal f@ f0<>
- IF
- \ RGA mod -- use absolute value to find exponent 00005
- unpreal f@ fdup fabs unpreal f!
- BEGIN unpreal f@ unpmult f@ f/ fpexp unpp2 @ -
- 0>
- WHILE unpex @ 1+ dup unpex ! floatexp unpmult f! unpp2 !
- REPEAT
- \
- BEGIN unpreal f@ unpmult f@ f/ fpexp unpp2 @ - 1-
- 0<
- WHILE unpex @ 1- dup unpex ! floatexp unpmult f! unpp2 !
- REPEAT
- \
- \ RGA -- restore original floating point 00005
- unpreal f!
- unpreal f@ unpmult f@ f/ f1 unpp2 @ $ 100000 * - f*
- f100000000 f* f100000000 f* r*e16->d
- fpwarn @ if
- unpex @ 307 >
- IF ." UNPACK - ...warning fp infinity " abort then
- THEN
- ELSE 0.
- THEN unpex @
- ;
-
- : UNPKROUND ( d n1 n2 --- d n ) \ round unpacked num d,n1 to n2 sig dig
- \ n2 must be a number between 1 and 15
- sigdig ! >r dup -rot dabs \ for internal use
- sigdig @ 8 <= if 100000000 m/ swap drop
- 5 8 sigdig @ - 0 do 10 * loop >r r@ +
- r> dup + dup >r / r> *
- dup 999999999 > if 10 / r> 1+ >r then
- swap 0< if -1 * then 100000000 m*
- else 100000000 m/ swap
- 5 16 sigdig @ - 0 do 10 * loop >r r@ +
- r> dup + dup >r / r> *
- dup 100000000 >= if 100000000 - swap 1+
- dup 999999999 > if 10 / r> 1+ >r then swap
- then swap 100000000 m* rot s->d d+
- rot 0< if 0. dswap d- then
- then r> ;
-
- : PACK ( d n --- r ) \ d: signed double-integer mantissa
- 15 unpkround floatexp \ with 16 implied decimal places
- fnfrot >f \ n: signed integer exponent
- nffrot $ 100000 * + \ r: number in double ieee form
- f100000000 f/ f100000000 f/ f*
- fpwarn @ if fvs if ." PACK - ... warning fp infinity " abort then
- then ; \ ==FVG84 required
-
-
-
- variable E.CNT variable E.EXCNT \ for internal use
- dvariable F.MT variable F.EX dvariable F.MULT variable F.CFLG
- variable F.DIV variable F.CH variable F.FFLD
-
-
- : (F>ETEXT) ( d n --- adr count ) \ internal use
- effld @ 1+ unpkround
- 5 e.cnt ! (commas) @ >r no-commas
- <# dup abs s->d # # ddup d0= not
- IF # 1 e.cnt +!
- THEN ddrop
- 0<
- IF ascii - hold 1 e.cnt +!
- else e.plus @ if ascii + hold 1 e.cnt +! then
- then expsymbol @ hold
- dup -rot dabs 16 effld @ - 0
- DO # 1 hld +!
- LOOP
- effld @ ?dup if 0 do # loop then
- effld @ e.cnt +!
- dp-chars w@ hold # rot
- 0< if ascii - hold 1 e.cnt +! then
- fld @ dup 0<
- IF drop
- ELSE e.cnt @ - 1- dup 0> if 0 do 32 hold loop else drop then
- THEN
- #> r> (commas) !
- ;
-
- : F>ETEXT ( r --- addr count ) \ Converts fp to e-form text
- \ same as e. (below) but no printing
- fdup FPEXP 1023 > \ 00002
- IF
- fdrop " Infinity" count
- ELSE
- unpack (f>etext) \ ==extension to FVG84
- THEN
- ;
-
- : E. ( r1 --- ) \ display floating-point in exponential form
- f>etext \ uses the variable "fld" to indicate width of
- type space \ the display field (-1=variable width)
- ;
- \ if field is not wide enough for number,
- \ the number will be displayed overflowing the field
- \ uses the variable "effld" to indicate width of the
- \ mantissa fractional field (places after decimal point)
- \ (min = 0 max = 6)
- \ uses the variable "e.plus". if true a + is placed
- \ after the "e" so that e+06 and e-06 will line up.
- \ ==FVG84 required with extended features
-
- : E.R ( r n1 n2 --- ) \ e form display of floating point number
- fld @ >r fld ! \ with n1 places to right of the decimal
- effld @ >r \ right justified in a field n2 characters wide.
- dup 7 < over -1 > and \ ==FVG84 optional
- not if drop r@ then effld !
- e. r> effld ! r> fld ! ;
-
-
- : (F>ENGTEXT) ( r --- addr count ) \ Converts fp to eng-form text
- \ same as eng. (below) but no printing
- (commas) @ >r no-commas \ ==extension to FVG84
- unpack effld @ 1+ unpkround
- dup 3 mod dup 0< if 3 + then dup e.excnt ! -
- 5 e.cnt !
- <# dup abs s->d # # ddup d0= not if # then ddrop
- 0< if ascii - hold 1 e.cnt +!
- else e.plus @ if ascii + hold 1 e.cnt +! then
- then expsymbol @ hold
- dup -rot dabs 16 effld @ - 0 do # 1 hld +! loop
- effld @ e.excnt @ - ?dup if 0 do # loop then
- effld @ e.cnt +!
- dp-chars w@ hold
- e.excnt @ 1+ 0 do # loop rot
- 0< if ascii - hold 1 e.cnt +! then
- fld @ dup 0< if drop
- else e.cnt @ - 1- dup 0> if 0 do 32 hold loop else drop then
- then
- #> r> (commas) ! ;
-
- : F>ENGTEXT ( r --- addr count ) \ Converts fp to eng-form text
- fdup FPEXP 1023 > \ 00002
- IF
- fdrop " Infinity" count
- ELSE
- (f>engtext)
- THEN
- ;
-
- : ENG. ( r1 --- ) \ display floating-point in engineering exponential form
- f>engtext \ with exponents ...,-06,-03,00,03,06,...
- type space ; \ uses the variable "fld" to indicate width of
- \ the display field (-1=variable width)
- \ if field is not wide enough for number,
- \ the number will be displayed overflowing the field
- \ uses the variable "effld" to indicate width of the
- \ mantissa display field. (effld + 1 = num sig dig)
- \ (effld min = 0, effld max = 6)
- \ uses the variable "e.plus". if true a + is placed
- \ after the "e" so that e+06 and e-06 will line up.
- \ ==extension to FVG84
-
-
- : ENG.R ( r n1 n2 --- ) \ engineering form display of r with
- fld @ >r fld ! \ with n1 + 1 significant digits
- effld @ >r \ right justified in a field n2 characters wide
- dup 7 < over -1 > and \ ==extension of FVG84
- not if drop r@ then effld !
- eng. r> effld ! r> fld ! ;
-
-
- : -COMMA? \ for internal use
- (commas) @ if
- f.cflg @ 1+ 3 mod dup f.cflg !
- 0= if dp-chars 2+ w@ 1 f.ch +! then
- then ;
-
- : +COMMA? \ for internal use
- (commas) @ if
- f.cflg @ 1- 3 mod dup f.cflg !
- 0= if dp-chars 2+ w@ 1 f.ch +! then
- then ;
-
- code B->BCD \ for internal use
- dsp a@+ 1dr dn move 16 # 3dr dn move
- 1 br: 0dr dn clr 1 # 2dr dn move
- 2 br: tos dn word swap tos dn 0dr dn word move
- 10 # 0dr dn word divu 0dr dn tos dn word move
- 2dr dn 2 word dbra 1 # 2dr dn move
- 3 br: 1dr dn word swap 1dr dn 0dr dn word move
- 10 # 0dr dn word divu 0dr dn 1dr dn word move
- 2dr dn 3 word dbra 0dr dn word swap
- $ f # 0dr dn and 0dr dn dsp -a@ move
- 3dr dn 1 word dbra 7 # 2dr dn move
- 4 br: 4 # tos dn lsl dsp a@+ tos dn or
- 2dr dn 4 word dbra 7 # 2dr dn move
- 5 br: 4 # 1dr dn lsl dsp a@+ 1dr dn or
- 2dr dn 5 word dbra 1dr dn dsp a@ move
- rts end-code
-
- code (NEXTDIGIT) \ for internal use
- 4 # tos dn rol tos dn 0dr dn move
- $ f # tos dn and $ fffffff0 # 0dr dn and
- dsp a@ 2dr dn move 4 # 2dr dn rol
- 2dr dn 3dr dn move $ fffffff0 # 2dr dn and
- $ f # 3dr dn and 3dr dn 0dr dn or
- 2dr dn dsp a@ move 0dr dn dsp -a@ move
- rts end-code
-
- : NEXTDIGIT ( --- c1 ) \ put next dig on stack
- f.div @ 0> if \ for internal use
- f.mt d@ (nextdigit) fnswap f.mt d!
- f.div @ 1- f.div !
- else 0
- then ascii 0 + 1 f.ch +! ;
-
- : F.-EX \ used by f. when exp is <0
- \ for internal use
- f.ffld @ 0= if ascii 0 dp-chars w@ 2 f.ch +!
- else dp-chars w@ 1 f.ch +! 0 f.cflg !
- f.ffld @ 0 do 1 f.ex +!
- f.ex @ 0< if ascii 0 1 f.ch +!
- else nextdigit then
- f.mt d@ d0= ffld @ 0< and if leave
- else f.ffld @ i 1+ > if -comma? then
- then
- loop
- then ;
-
- : F.+EX \ used by f. when exp is 0>=
- \ for internal use
- f.ex @ 1+ 0 do nextdigit +comma? loop
- (commas) @ if drop -1 f.ch +! then 0 f.cflg !
- dp-chars w@ 1 f.ch +!
- ffld @ 0< if
- f.mt d@ d0= not if
- f.ffld @ 0 do nextdigit
- f.mt d@ d0= if leave
- else f.ffld @ i 1+ > if -comma? then
- then
- loop
- then
- else
- ffld @ 0 do nextdigit loop
- then ;
-
- : SET-F.FFLD ( --- ) \ Sets f.ffld - used by f>text
- ffld @ 0< if 15 \ for internal use
- else
- ffld @ 1+
- f.ex @ + dup 15 > if drop 15 then
- then f.ffld ! ;
-
- : (F>TEXT) ( r --- addr count ) \ Converts fp to text
- \ same as f. (below) but no printing
- unpack \ ==extension to FVG84
- f.ex ! f.mt d!
- set-f.ffld
- f.mt d@ f.ex @ f.ffld @ unpkround f.ex ! f.mt d!
- f.ex @ 0< if
- ffld @ dup 0< if drop 15 then f.ex @ +
- 0< if 0 f.ex ! 0 0 f.mt d! set-f.ffld then
- then
- f.ex @ ffld @ 0< if abs then f.exmax @ > if
- f.mt d@ f.ex @ (f>etext)
- else
- f.ex @ 1+ 3 mod dup 0< if 3 + then f.cflg !
- f.ffld @ f.ex @ - 1- dup 0< if drop 0 then
- dup 15 > if drop 15 then f.ffld !
- 0 f.ch ! 16 f.div !
- f.mt @ f.mult !
- f.mt d@ dabs b->bcd f.mt d!
- f.ex @ 0< if f.-ex else f.+ex then
- f.endpoint @ 0= over dp-chars w@ = and if drop -1 f.ch +! then
- <# f.ch @ 0 do hold loop
- f.mult @ 0< if ascii - hold 1 f.ch +! then
- fld @ dup 0< if drop
- else
- f.ch @ - 1- dup 0> if 0 do 32 hold loop else drop then
- then
- 0 0 #>
- then
- ;
-
- : F>TEXT ( r --- addr count ) \ Converts fp to text
- fdup FPEXP 1023 > \ 00002
- IF
- fdrop " Infinity" count
- ELSE
- (f>text)
- THEN
- ;
-
- : F. ( r1 --- ) \ display floating-point in decimal form
- f>text type \ uses the variable "fld" to indicate width of
- space ; \ the display field (-1=variable width)
- \ if field is not wide enough for number,
- \ the number will be displayed overflowing the field
- \ uses the variable "ffld" to indicate width
- \ of the fractional field (places after decimal point)
- \ (-1=variable width) (max 6 if r1 >= 1., 7 if < 1.)
- \ ==FVG84 required with extended features
-
- : F.R ( r n1 n2 --- ) \ display fp with n1 fractional places
- fld @ >r fld ! \ right justified in a field n2 characters wide
- ffld @ >r ffld ! \ ==FVG84 optional
- f. r> ffld ! r> fld ! ;
-
-
-
- : PLACES ( n --- ) \ sets default number of fractional digits
- ffld ! ; \ when fp number is displayed by f.
- \ ==FVG84 required
-
-
- variable E.LOCATION variable MANT.LENGTH \ all for internal use
- create E.STRING 30 allot variable EXP.LENGTH variable NTYPE
- ascii E 256 * ascii e + constant ASCII-Ee
-
-
- code cmatch? ( string cnt b --- pointer-to-matching-char-in-string | false )
- \ the "byte" may be 2 bytes - e.g. ascii E 256 * ascii e +
- dsp a@+ 0dr dn move dsp a@+ 1dr dn move
- org an 0ar an move 1dr dn 0ar an adda
- 0dr dn 1dr dn add 0dr dn neg
- tos dn 2dr dn move 8 # 2dr dn lsr
- 1 br: 0ar a@ tos dn byte cmp 2 beq
- 0ar a@+ 2dr dn byte cmp 2 beq
- 1 # 0dr dn addq 1 blt
- 0 # tos dn move 3 bra
- 2 br: 0dr dn 1dr dn add 1dr dn tos dn move
- 3 br: rts end-code
-
- \ --- BEGIN 00003 -----------
- : FASTFP.NUMBER? ( addr --- r true | d true | false )
- \ Converts string at addr to number
- \ if it contains a decimal point,
- \ it will be converted to floating.
- \ Maximum input = 18 digits but only
- \ 7 significant digits are retained.
- 0 ntype !
- dup count swap c@ ascii - = +
- 20 <
- IF number?
- ELSE drop false exit
- THEN
- IF base @ 10 = dpl @ 1+ 0> and
- IF >f 0 dpl ! 2
- ELSE 1
- THEN ntype !
- ELSE false exit
- THEN
- true
- ;
-
- : FLOAT.NUMBER? ( addr --- r1 true | false )
- \ translate counted string to floating
- \ Examples of acceptable numbers:
- \ 123 1.234 12.34e5 12.34E5 1.234e+5
- \ 2e5 e5 negatives in both mantissa
- \ and exponent, but not -e5 - it must be
- \ -1e5. Max exp is +/- 308.
- \ Max mantissa input = 18 digits but
- \ only 15 significant digits are retained
- \ ==extension to FVG84
- 0 ntype ! dup count ascii-Ee cmatch?
- IF base @ 10 = not
- IF fastfp.number?
- ELSE e.string over c@ 1+
- dup 26 <
- IF cmove
- ELSE 2drop drop false exit \ main too long
- THEN
- e.string count ascii-Ee cmatch? e.location !
- e.location @ e.string - 1- mant.length !
- e.string c@ mant.length @ - 1- exp.length !
- mant.length @ e.string c!
- exp.length @ e.location @ c!
- e.string count swap c@ ascii - = + 19 >
- IF false exit
- THEN
- ( dp-chars 2+ w@ >r dp-chars w@ dp-chars 2+ w! )
- e.string dup c@ 0=
- IF drop 1 0 -1 dup dpl !
- ELSE number?
- THEN
- IF >f e.location @ number?
- ( r> dp-chars 2+ w! )
- dpl @ -1 = and
- IF drop floatexp f>r $ 100000 * + fr> f*
- finfinity fover f= fnover f-infinity f= or fpwarn @ and
- if ." FLOAT.NUMBER - ...warning fp infinity " abort then
- 0 dpl ! 2 ntype !
- ELSE
- 2drop false exit \ bad exponent
- THEN
- ELSE
- ( r> dp-chars 2+ w! )
- false exit \ bad main number
- THEN
- true
- THEN
- ELSE fastfp.number?
- THEN
- ;
-
- : FASTFP.NUMBER ( addr --- r 0 | n 0 )
- fastfp.number? 0=
- IF
- 0 error
- THEN
- ;
-
- : FLOAT.NUMBER ( addr --- r 0 | n 0 )
- float.number? 0=
- IF
- 0 error
- THEN
- ;
-
- : FNUMBER? ( addr --- r true | false ) \ convert string to floating point
- float.number? ntype @ 2 <
- IF 2drop false
- THEN
- ;
-
- : FNUMBER ( addr --- r ) \ convert string to floating point
- \ ==FVG84 optional
- fnumber? 0= if 0 error then
- ;
- \ --- END 00003 ----------
-
- : SMUDGE0123 \ smudge the names of numbers so ntype won't be circumvented
- ' 0 ' 1 ' 2 ' 3 4 0 do >name dup c@ 32 or swap c! loop
- hash-damaged on ; \ internal use
-
- : UNSMUDGE0123 \ unsmudge the names of numbers so they can be found
- ' 0 ' 1 ' 2 ' 3 4 0 do >name dup c@ 223 and swap c! loop
- hash-damaged on ; \ internal use
-
- : FLOAT.INTERPRET ( --- ) \ integer, decimal form, or "E" form
- ' float.number \ decimal point indicates floating point
- is number
- \ smudge0123
- open-mathlibs
- ; \ ==extension to FVG84
-
- : FIX.INTERPRET ( --- ) \ put it back the old way
- ' (number) \ ==extension to FVG84
- is number 0 ntype !
- \ unsmudge0123
- ;
-
-
- : FASTFP.INTERPRET ( --- ) \ integer or decimal form (no "E" form)
- ' fastfp.number \ decimal point indicates floating point
- is number
- \ smudge0123
- open-mathlibs ; \ ==extension to FVG84
-
-
- : FPINIT ( -- )
- open-mathlibs float.interpret 0 ntype !
- ;
-
- : FPTERM ( -- )
- fix.interpret close-mathlibs
- ;
-
- only forth definitions
-
- : AUTO.INIT ( -- , start floating point if loaded)
- auto.init fpinit
- ." Floating Point Initialized!" cr
- ;
-
- : AUTO.TERM ( -- , term floating point if loaded 00003 )
- fpterm auto.term \ 00004
- ;
-
- \ Reset NUMBER vector if this code forgotten.
- if.forgotten fpterm
-
- close-mathlibs
-
- cr ." Enter: FPINIT to start floating point" cr
-
-